//Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace Microsoft.Office.OneNote
{
	public class SectionGroup : Folder
	{
		public SectionGroup()
		{
		}

		public SectionGroup(string name)
		{
			this.Name = name;
		}

		/// <summary>
		/// Clones the Unfiled Notes notebook.
		/// </summary>
		/// <returns>A deep copy of this notebook.</returns>
		public override object Clone()
		{
			Section clone = new Section();
			clone.Id = this.Id;

			return clone;
		}

		/// <summary>
		/// Useful for debugging.
		/// </summary>
		/// <returns>A string representation of the Notebook.</returns>
		public override string ToString()
		{
			return this.Name;
		}

		/// <summary>
		/// Used while committing all pending additions to commit any newly created
		/// node to OneNote.
		/// </summary>
		/// <param name="serializedId">The new ID of this node.</param>
		protected internal override void AddHierarchyToOneNote(out string serializedId)
		{
			Debug.Assert(this.Id == ObjectId.Empty);

			// Create the section group via OpenHierarchy:
			string parentId = null;
			if (this.Parent is HierarchyNode)
			{
				parentId = ((HierarchyNode) this.Parent).Id.ToString();
			}

			string path = this.Path;
			if (path == "")
			{
				path = this.Name;
			}

			Application.Server.OpenHierarchy(path, parentId, out serializedId, CreateFileType.Folder);
		}

		/// <summary>
		/// The serialized Xml element type 
		/// </summary>
		protected override internal string SerializedXmlType
		{
			get { return "SectionGroup"; }
		}
	}
}
